package beans;

import beans.util.PageBean;
import org.apache.log4j.Logger;

import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.Serializable;

/**
 * Created by Волков Олег on 05.05.14.
 */
public class AutorisationErrorBean extends PageBean implements Serializable {

    private static final Logger logger = Logger.getLogger(AutorisationErrorBean.class);

    private String pageURL = "login";

    public void goToLoginPage() {
        HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
        try {
            response.sendRedirect(pageURL);
            HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
            session.invalidate();
        } catch (IOException e) {
            logger.error("I/O problems: " + e.getMessage());
        }
    }

}
